package model

import (
	"manager/model/entity"
)

type UserEbikeCreateRequest struct {
	UserID int64 `json:"user_id"`

	EbikeID int64 `json:"ebike_id"`

	ShareTime int64 `json:"share_time"`

	IsManager int `json:"is_manager"`
}

type UserEbikeUpdateRequest struct {
	ID int64 `json:"id"`

	UserID *int64 `json:"user_id"`

	EbikeID *int64 `json:"ebike_id"`

	ShareTime *int64 `json:"share_time"`

	IsManager *int `json:"is_manager"`
}

type UserEbikeRequest struct {
	UserID *int64 `json:"user_id"`

	EbikeID *int64 `json:"ebike_id"`

	IsManager *int `json:"is_manager"`
}

type UserEbikeListRequest struct {
	Index int `json:"index"`
	Size  int `json:"size"`

	ID int64 `json:"id"`

	UserID *int64 `json:"user_id"`

	EbikeID *int64 `json:"ebike_id"`

	ShareTime int64 `json:"share_time"`

	IsManager *int `json:"is_manager"`
}

type UserEbikeListResponse struct {
	Total int              `json:"total"`
	Data  []*UserEbikeInfo `json:"data"`
}

type UserEbikeInfo struct {
	ID int64 `json:"id"`

	UserID int64 `json:"user_id"`

	EbikeID int64 `json:"ebike_id"`

	ShareTime int64 `json:"share_time"`

	IsManager int `json:"is_manager"`

	Photo string `json:"photo"`

	CreatedAt int64 `json:"created_at"`

	UpdatedAt int64 `json:"updated_at"`
}

type UserEbikeAndEbikeInfo struct {
	UserID int64 `json:"user_id"`

	EbikeID int64 `json:"ebike_id"`

	ShareTime int64 `json:"share_time"`

	IsManager int `json:"is_manager"`

	Photo string `json:"photo"`

	CreatedAt int64 `json:"created_at"`

	UpdatedAt int64 `json:"updated_at"`

	SnCode string `json:"sn_code"`
}

type UserEbikeAndEbikeResponse struct {
	ID int64 `json:"id"`

	UserID int64 `json:"user_id"`

	EbikeID int64 `json:"ebike_id"`

	ShareTime int64 `json:"share_time"`

	IsManager int `json:"is_manager"`

	Photo string `json:"photo"`

	CreatedAt int64 `json:"created_at"`

	UpdatedAt int64 `json:"updated_at"`

	SnCode string `json:"sn_code"`

	EbikeInfo EbikeInfo `json:"ebike_info"`
}

type UserEbikeDeleteRequest struct {
	ID int64 `json:"id"`
}

type FindCountByIdsResponse struct {
	ID    int64 `json:"id"`
	Count int64 `json:"count"`
}

// UserBikeDetailRequest 用户车辆详情
type UserBikeDetailRequest struct {
	UserId  int64 `json:"user_id"`
	EbikeId int64 `json:"ebike_id"`
}

type UserBikeDetailResponse struct {
	// 车辆名称
	Name string `json:"name"`
	// 车辆图片
	Photo string `json:"photo"`

	// 车辆状态
	IsManager int `json:"is_manager"`
}

// UserEbikeBindInfoRequest 用户车辆绑定数据请求
type UserEbikeBindInfoRequest struct {
	EbikeId *int64 `json:"ebike_id"`
}

type UserEbikeBindInfoResponse struct {
	EbikeMasterId  int64   `json:"ebike_master_id"`
	ShareUserIds   []int64 `json:"share_user_ids"`
	MasterBindTime int64   `json:"master_bind_time"`
}

// BikeManagerRequest 用户车辆绑定请求
type BikeManagerRequest struct {
	Sn string `json:"sn"`
}

type BikeManagerResponse struct {
	Sn     string `json:"sn"`
	UserId int64  `json:"user_id"`
}

func UserEbikesEntityToDto(userEbikes []*entity.UserEbike) []*UserEbikeInfo {
	out := make([]*UserEbikeInfo, 0, len(userEbikes))
	for _, c := range userEbikes {
		out = append(out, UserEbikeEntityToDto(c))
	}
	return out
}

func UserEbikeEntityToDto(e *entity.UserEbike) *UserEbikeInfo {
	return &UserEbikeInfo{

		ID: e.ID,

		UserID: e.UserID,

		EbikeID: e.EbikeID,

		ShareTime: e.ShareTime,

		IsManager: e.IsManager,

		Photo: e.Photo,

		CreatedAt: e.CreatedAt,

		UpdatedAt: e.UpdatedAt,
	}
}

// CustomUserEbikeInfo 自定义用户车辆信息
type CustomUserEbikeInfo struct {
	BikeId int64  `json:"bike_id"`
	Image  string `json:"image"`
	Name   string `json:"name"`
}
